package cn.flyingroc.travelbook;

import java.io.File;

import android.app.AlertDialog;
import android.app.TabActivity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.TabHost;
import android.widget.Toast;

public class Main extends TabActivity {

	private TabHost tabs;
	private final static String TAG = "Main";
	
	public static final String PHOTO_PATH = "/sdcard/TravelBook/Photo/";
	
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		
		//init file folder
        File file = new File(PHOTO_PATH);
        if(!file.exists()){
        	file.mkdirs();
        }
        Log.i(TAG,file.exists()?"file exists":"file not exists");
        
        //init tabs
		tabs = getTabHost();
		
		TabHost.TabSpec allTab = tabs.newTabSpec("mypois");
        Intent all = new Intent(this, MyPOIList.class);
        allTab.setContent(all);
        allTab.setIndicator("我的兴趣点", this.getResources().getDrawable(R.drawable.message_32));
        tabs.addTab(allTab);
		
        TabHost.TabSpec repliesTab = tabs.newTabSpec("mybooks");
        Intent replies = new Intent(this, MyBookList.class);
        repliesTab.setContent(replies);
        repliesTab.setIndicator("我的路书", this.getResources().getDrawable(R.drawable.message_32));
        tabs.addTab(repliesTab);
        
        TabHost.TabSpec listTab = tabs.newTabSpec("target");
        Intent list = new Intent(this, TargetPoint.class);
        listTab.setContent(list);
        listTab.setIndicator("目标地理", this.getResources().getDrawable(R.drawable.message_32));
        tabs.addTab(listTab);
        
        //reveive activity put parameter
        Bundle bundle = getIntent().getExtras();
        Log.i(TAG, bundle==null?"bundle==null":"bundle<>null");
        if (bundle!=null){
        	String name = bundle.getString("source");
            if(name.equals(NewPOI.TAG)){
            	tabs.setCurrentTabByTag("mypois");
            }
        }else{
        	tabs.setCurrentTabByTag("mypois");
        }
        
	}
	
	
	
	public static void mMakeTextToast(Context context,String str,boolean isLong){
		if(isLong==true){
			Toast.makeText(context, str, Toast.LENGTH_LONG).show();
		}else{
			Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
		}
	}
	
	@Override
	protected void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
	}

	@Override
	protected void onStop() {
		// TODO Auto-generated method stub
		super.onStop();
	}

	
	
}
